package com.kajespero.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.kajespero.model.annotation.MappedValue;
import com.kajespero.model.annotation.enums.RelationType;
import com.kajespero.vo.SummaryVO;
import com.kajespero.webapp.editor.annotation.PropertyEditorSupport;
import com.kajespero.webapp.editor.impl.SummaryPropertyEditorSupport;

@PersistenceCapable
public class SummaryBean extends IdentifierVOBean<Long> implements SummaryVO{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2018034664427028162L;
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private Long id;

	@Persistent
	private String title;
	
	@Persistent
	private String url;
	
	@NotPersistent
	@PropertyEditorSupport(editor=SummaryPropertyEditorSupport.class, fieldName="owner", attributeName="id")
	@MappedValue(type=SummaryBean.class, relationType=RelationType.MANY_TO_ONE, mappedBy="ownerId")
	private SummaryBean owner;
	
	@Persistent
	private Key ownerId;

	@Override
	public Long getId() {
		return this.id;
	}

	@Override
	public String getTitle() {
		return this.title;
	}

	@Override
	public String getUrl() {
		return this.url;
	}

	@Override
	public SummaryBean getOwner() {
		return this.owner;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public void setOwner(SummaryBean owner) {
		this.owner = owner;
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public Key getOwnerKey() {
		return ownerId;
	}

	public void setOwnerKey(Key ownerId) {
		this.ownerId = ownerId;
	}

}
